﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Util.Domains;
using Util.Domains.Auditing;

namespace IterationLife.Domains.Sports.Models {
    /// <summary>
    /// 体育队伍
    /// </summary>
    [Description( "体育队伍" )]
    public partial class SportTeam : AggregateRoot<SportTeam>,IDelete,IAudited {
        /// <summary>
        /// 初始化体育队伍
        /// </summary>
        public SportTeam() : this( Guid.Empty ) {
        }

        /// <summary>
        /// 初始化体育队伍
        /// </summary>
        /// <param name="id">体育队伍标识</param>
        public SportTeam( Guid id ) : base( id ) {
            SportAthletes = new List<IterationLife.Domains.Sports.Models.SportAthlete>();
            SportEventGroups = new List<IterationLife.Domains.Sports.Models.SportEventGroup>();
        }

        /// <summary>
        /// 合作方队伍Id
        /// </summary>
        [Required(ErrorMessage = "合作方队伍Id不能为空")]
        [StringLength( 200, ErrorMessage = "合作方队伍Id输入过长，不能超过200位" )]
        public string PartnerTeamId { get; set; }
        /// <summary>
        /// 名字
        /// </summary>
        [Required(ErrorMessage = "名字不能为空")]
        [StringLength( 50, ErrorMessage = "名字输入过长，不能超过50位" )]
        public string Name { get; set; }
        /// <summary>
        /// 队标
        /// </summary>
        [StringLength( 500, ErrorMessage = "队标输入过长，不能超过500位" )]
        public string Logo { get; set; }
        /// <summary>
        /// 人数
        /// </summary>
        public int PersonCount { get; set; }
        /// <summary>
        /// 历史平均数据
        /// </summary>
        public string HistoryAverageJsonData { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public Guid? CreatorId { get; set; }
        /// <summary>
        /// 最后修改时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }
        /// <summary>
        /// 最后修改人
        /// </summary>
        public Guid? LastModifierId { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        [Required(ErrorMessage = "是否删除不能为空")]
        public bool IsDeleted { get; set; }
        
        /// <summary>
        /// 运动员列表
        /// </summary>
        public virtual ICollection<IterationLife.Domains.Sports.Models.SportAthlete> SportAthletes { get; set; }
        
        /// <summary>
        /// 体育比赛分组列表
        /// </summary>
        public virtual ICollection<IterationLife.Domains.Sports.Models.SportEventGroup> SportEventGroups { get; set; }
        
        /// <summary>
        /// 添加描述
        /// </summary>
        protected override void AddDescriptions() {
            AddDescription( "体育队伍编号", Id );
            AddDescription( "合作方队伍Id", PartnerTeamId );
            AddDescription( "名字", Name );
            AddDescription( "队标", Logo );
            AddDescription( "人数", PersonCount );
            AddDescription( "历史平均数据", HistoryAverageJsonData );
            AddDescription( "创建时间", CreationTime );
            AddDescription( "创建人", CreatorId );
            AddDescription( "最后修改时间", LastModificationTime );
            AddDescription( "最后修改人", LastModifierId );
        }
        
        /// <summary>
        /// 添加变更列表
        /// </summary>
        protected override void AddChanges( SportTeam newEntity ) {
            AddChange( "Id", "体育队伍编号", Id, newEntity.Id );            
            AddChange( "PartnerTeamId", "合作方队伍Id", PartnerTeamId, newEntity.PartnerTeamId );
            AddChange( "Name", "名字", Name, newEntity.Name );
            AddChange( "Logo", "队标", Logo, newEntity.Logo );
            AddChange("PersonCount", "人数", PersonCount, newEntity.PersonCount);
            AddChange( "HistoryAverageJsonData", "历史平均数据", HistoryAverageJsonData, newEntity.HistoryAverageJsonData );
            AddChange( "CreationTime", "创建时间", CreationTime, newEntity.CreationTime );
            AddChange( "CreatorId", "创建人", CreatorId, newEntity.CreatorId );
            AddChange( "LastModificationTime", "最后修改时间", LastModificationTime, newEntity.LastModificationTime );
            AddChange( "LastModifierId", "最后修改人", LastModifierId, newEntity.LastModifierId );
        }
    }
}